package com.newtouch.bxzs.business.personal.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.newtouch.bxzs.business.config.MyLog;
import com.newtouch.bxzs.business.personal.model.AddFeedbackProblemVO;
import com.newtouch.bxzs.business.personal.model.AnswerFeedbackProblemVO;
import com.newtouch.bxzs.business.personal.model.FeedbackProblemBO;
import com.newtouch.bxzs.business.personal.model.FeedbackProblemVO;
import com.newtouch.bxzs.business.personal.service.FeedbackProblemService;
import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 反馈问题控制器
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2020年12月30日</td>
 * <td>xiongdianqiang</td>
 * <td>Create</td>
 * </tr>
 * </table>
 * 
 * @author xiongdianqiang
 * 
 * @version 1.0.0
 * @since 1.0.0
 */
@RestController
@SuppressWarnings("unchecked")
@Api(tags = "维护反馈问题")
@RequestMapping(value = "/feedbackProblemController")
public class FeedbackProblemController {

	@Autowired
	private FeedbackProblemService feedbackProblemService;

	/** 静态变量：系统日志 */
	private static final Log logger = LogFactory.getLog(FeedbackProblemController.class);

	@ApiOperation("获取反馈问题列表")
	@PostMapping(value = "/getFeedbackProblemList")
	@MyLog(systemFunctionName = "维护反馈问题", systemFunctionUrl = "/feedbackProblemController/getFeedbackProblemList", userOperationType = 4, userOperationSummary = "获取反馈问题列表")
	public BaseResponse<IPage<FeedbackProblemBO>> getFeedbackProblemList(
			@RequestBody FeedbackProblemVO feedbackProblemVO) {
		logger.info("开始查询反馈列表");
		IPage<FeedbackProblemBO> feedbackProblemList = feedbackProblemService.getFeedbackProblemList(feedbackProblemVO);
		return RespGenerator.returnOK(feedbackProblemList);
	}

	@ApiOperation("获取问题反馈详情")
	@GetMapping(value = "/getFeedbackProblemDetail")
	@ApiImplicitParam(name = "problemFeedbackId", value = "反馈问题id", required = true, paramType = "query", dataType = "String")
	@MyLog(systemFunctionName = "维护反馈问题", systemFunctionUrl = "/feedbackProblemController/getFeedbackProblemDetail", userOperationType = 4, userOperationSummary = "获取问题反馈详情")
	public BaseResponse<FeedbackProblemBO> getFeedbackProblemDetail(
			@RequestParam(value = "problemFeedbackId") String problemFeedbackId) {
		logger.info("获取问题反馈详情");
		return RespGenerator.returnOK(feedbackProblemService.getFeedbackProblemDetailById(problemFeedbackId));
	}
	
	@ApiOperation("解答反馈问题")
	@PostMapping(value = "/answerFeedbackProblem")
	@MyLog(systemFunctionName = "维护反馈问题", systemFunctionUrl = "/feedbackProblemController/answerFeedbackProblem", userOperationType = 2, userOperationSummary = "解答反馈问题")
	public BaseResponse<FeedbackProblemBO> answerFeedbackProblem(
			@RequestBody AnswerFeedbackProblemVO answerFeedbackProblemVO) {
		logger.info("解答反馈问题");
		return RespGenerator.returnOK(feedbackProblemService.answerFeedbackProblem(answerFeedbackProblemVO));
	}
	
	@ApiOperation("新增反馈问题")
	@PostMapping(value = "/addFeedbackProblem")
	@MyLog(systemFunctionName = "维护反馈问题", systemFunctionUrl = "/feedbackProblemController/addFeedbackProblem", userOperationType = 1, userOperationSummary = "新增反馈问题")
	public BaseResponse<String> addFeedbackProblem(@RequestBody AddFeedbackProblemVO addFeedbackProblemVO) {
		logger.info("新增反馈问题");
		return RespGenerator.returnOK(feedbackProblemService.addFeedbackProblem(addFeedbackProblemVO));
	}

	@PostMapping(value = "/revokeFeedbackProblem")
	@ApiOperation("撤回反馈问题")
	@ApiImplicitParam(name = "problemFeedbackId", value = "反馈问题id", paramType = "query", dataType = "String", required = true)
	@MyLog(systemFunctionName = "维护反馈问题", systemFunctionUrl = "/feedbackProblemController/revokeFeedbackProblem", userOperationType = 2, userOperationSummary = "撤回反馈问题")
	public BaseResponse<String> revokeFeedbackProblem(
			@RequestParam(value = "problemFeedbackId") String problemFeedbackId) {
		logger.info("撤回反馈问题");
		feedbackProblemService.revokeFeedbackProblem(problemFeedbackId);
		return RespGenerator.returnOK("成功！");
	}
}
